﻿Imports System.Data.SqlClient
Public Class EmployeeView

    Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click

        Dim frm As New EmployeeAdd
        If (frm.ShowDialog() = Windows.Forms.DialogResult.OK) Then
            LoadData()
        End If
    End Sub

    Private Sub LoadData()
        cmd.Parameters("@S") = "%" & textsearch.Text & "%"
        Dim dt As DataTable = cmd.ExecuteDataTable("SELECT * FROM Employee  WHERE EmployeeName LIKE @S AND Active=1;")
        Me.DataGridView1.DataSource = dt
    End Sub

    Private Sub textsearch_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles textsearch.TextChanged
        LoadData()
    End Sub

    Private Sub formEmployeeview_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        UI.FormatDataGrid(Me.DataGridView1)
        LoadData()
    End Sub
End Class